home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 1998 November / IRIX 6.5.2 Base Documentation November 1998.img / usr / share / catman / u_man / cat1 / tr.z / tr
Text File  |  1998-10-20  |  20KB  |  326 lines

  1.  
  2.  
  3.  
  4. ttttrrrr((((1111))))                                                                    ttttrrrr((((1111))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      _tttt_rrrr - translate characters
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      _tttt_rrrr _[[[[_----_cccc_dddd_ssss_]]]] _[[[[_s_t_r_i_n_g_1 _[[[[_s_t_r_i_n_g_2_]]]]_]]]]
  13.      _tttt_rrrr _[[[[_----_cccc_ssss_]]]] _s_t_r_i_n_g_1 _s_t_r_i_n_g_2
  14.      _tttt_rrrr _----_ssss_[[[[_----_cccc_]]]] _s_t_r_i_n_g_1
  15.      _tttt_rrrr _----_dddd_[[[[_----_cccc_]]]] _s_t_r_i_n_g_1
  16.      _tttt_rrrr _----_dddd_ssss_[[[[_----_cccc_]]]] _s_t_r_i_n_g_1 _s_t_r_i_n_g_2
  17.  
  18. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  19.      _tttt_rrrr copies the standard input to the standard output with substitution or
  20.      deletion of selected characters.  Input characters found in _s_t_r_i_n_g_1 are
  21.      mapped into the corresponding characters of _s_t_r_i_n_g_2.  _tttt_rrrr processes
  22.      supplementary code set characters according to the locale specified in
  23.      the _LLLL_CCCC______CCCC_TTTT_YYYY_PPPP_EEEE environment variable [see _LLLL_AAAA_NNNN_GGGG on _eeee_nnnn_vvvv_iiii_rrrr_oooo_nnnn(5)].  Searches and
  24.      translations are performed on characters, not bytes.
  25.  
  26.      The following options are supported:
  27.  
  28.      _----_cccc      Complements the set of characters in _s_t_r_i_n_g_1 with respect to the
  29.              universe of characters whose codes are 001 through 377 octal.
  30.  
  31.      _----_dddd      Deletes all input characters in _s_t_r_i_n_g_1.
  32.  
  33.      _----_ssss      Squeezes all strings of repeated output characters that are in
  34.              _s_t_r_i_n_g_2 to single characters.
  35.  
  36.      The following abbreviation conventions may be used to introduce ranges of
  37.      characters or repeated characters into the strings:
  38.  
  39.      _[[[[_aaaa_----_zzzz_]]]]   Stands for the string of characters whose ASCII codes run from
  40.              character _aaaa to character _zzzz, inclusive.
  41.  
  42.      _[[[[_aaaa_****_n_]]]]   Stands for _n repetitions of _aaaa.  If the first digit of _n is _0000, _n
  43.              is considered octal; otherwise, _n is taken to be decimal.  A zero
  44.              or missing _n is taken to be huge; this facility is useful for
  45.              padding _s_t_r_i_n_g_2.
  46.  
  47.      The escape character _\\\\ may be used as in the shell to remove special
  48.      meaning from any character in a string.  In addition, _\\\\ followed by 1, 2,
  49.      or 3 octal digits stands for the character whose code is given by those
  50.      digits.  When octal notation with the backslash (\) escape character is
  51.      used, a backslash is placed before each byte of multibyte characters.
  52.  
  53. EEEEXXXXTTTTEEEENNNNDDDDEEEEDDDD DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  54.      The operands _s_t_r_i_n_g_1 and _s_t_r_i_n_g_2 (if specified) define two arrays of
  55.      characters. The constructs in the following list can be used to specify
  56.      characters or single-character collating elements. If any of the
  57.      constructs result in multi-character collating elements, _tttt_rrrr will exclude,
  58.      without a diagnostic, those multi-character elements from the resulting
  59.      array.
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. ttttrrrr((((1111))))                                                                    ttttrrrr((((1111))))
  71.  
  72.  
  73.  
  74.      _cccc_hhhh_aaaa_rrrr_aaaa_cccc_tttt_eeee_rrrr
  75.              Any character not described by one of the conventions below
  76.              represents itself.
  77.  
  78.      _\\\\_oooo_cccc_tttt_aaaa_llll  Octal sequences can be used to represent characters with specific
  79.              coded values.  An octal sequence consists of a backslash followed
  80.              by the longest sequence of one-, two-  or three-octal-digit
  81.              characters (01234567). The sequence causes the character whose
  82.              encoding is represented by the one-, two- or three-digit octal
  83.              integer to be placed into the array. If the size of a byte on the
  84.              system is greater than nine bits, the valid escape sequence used
  85.              to represent a byte is implementation-dependent. Multi-byte
  86.              characters require multiple, concatenated escape sequences of
  87.              this type, including the leading _\\\\ for each byte.
  88.  
  89.      _\\\\_cccc_hhhh_aaaa_rrrr_aaaa_cccc_tttt_eeee_rrrr
  90.              The backslash-escape sequences (_\\\\_,,,, _\\\\_aaaa_,,,, _\\\\_bbbb_,,,, _\\\\_ffff_,,,, _\\\\_nnnn_,,,, _\\\\_rrrr_,,,, _\\\\_tttt_,,,, _\\\\_vvvv)
  91.              are supported.  The results of using any other character, other
  92.              than an octal digit, following the backslash are unspecified.
  93.  
  94.      _cccc_----_cccc     Represents the range of collating elements between the range
  95.              endpoints, inclusive, as defined by the current setting of the
  96.              LC_COLLATE locale category.  The starting endpoint must precede
  97.              the second endpoint in the current collation order. The
  98.              characters or collating elements in the range are placed in the
  99.              array in ascending collation sequence.
  100.  
  101.      _[[[[_::::_cccc_llll_aaaa_ssss_ssss_::::_]]]]
  102.              Represents all characters belonging to the defined character
  103.              class, as defined by the current setting of the LC_CTYPE locale
  104.              category. The following character class names will be accepted
  105.              when specified in _s_t_r_i_n_g_1:  _aaaa_llll_nnnn_uuuu_mmmm_,,,, _aaaa_llll_pppp_hhhh_aaaa_,,,, _bbbb_llll_aaaa_nnnn_kkkk_,,,, _cccc_nnnn_tttt_rrrr_llll_,,,, _dddd_iiii_gggg_iiii_tttt_,,,,
  106.              _gggg_rrrr_aaaa_pppp_hhhh_,,,, _llll_oooo_wwww_eeee_rrrr_,,,, _pppp_rrrr_iiii_nnnn_tttt_,,,, _pppp_uuuu_nnnn_cccc_tttt_,,,, _ssss_pppp_aaaa_cccc_eeee_,,,, _uuuu_pppp_pppp_eeee_rrrr_,,,, _xxxx_dddd_iiii_gggg_iiii_tttt
  107.  
  108.              In addition, character class expressions of the form _[[[[_::::_nnnn_aaaa_mmmm_eeee_::::_]]]] are
  109.              recognised in those locales where the name keyword has been given
  110.              a charclass definition in the LC_CTYPE category.
  111.  
  112.              When both the _----_dddd and _----_ssss options are specified, any of the
  113.              character class names will be accepted in _s_t_r_i_n_g_2. Otherwise,
  114.              only character class names _llll_oooo_wwww_eeee_rrrr or _uuuu_pppp_pppp_eeee_rrrr are valid in _s_t_r_i_n_g_2
  115.              and then only if the corresponding character class (_uuuu_pppp_pppp_eeee_rrrr and
  116.              _llll_oooo_wwww_eeee_rrrr, respectively) is specified in the same relative position
  117.              in _s_t_r_i_n_g_1. Such a specification is interpreted as a request for
  118.              case conversion. When _[[[[_::::_llll_oooo_wwww_eeee_rrrr_::::_]]]] appears in _s_t_r_i_n_g_1 and _[[[[_::::_uuuu_pppp_pppp_eeee_rrrr_::::_]]]]
  119.              appears in _s_t_r_i_n_g_2, the arrays will contain the characters from
  120.              the _tttt_oooo_uuuu_pppp_pppp_eeee_rrrr mapping in the LC_CTYPE category of the current
  121.              locale. When _[[[[_::::_uuuu_pppp_pppp_eeee_rrrr_::::_]]]] appears in _s_t_r_i_n_g_1 and _[[[[_::::_llll_oooo_wwww_eeee_rrrr_::::_]]]] appears
  122.              in _s_t_r_i_n_g_2, the arrays will contain the characters from the
  123.              _tttt_oooo_llll_oooo_wwww_eeee_rrrr mapping in the LC_CTYPE category of the current locale.
  124.              The first character from each mapping pair will be in the array
  125.              for _s_t_r_i_n_g_1 and the second character from each mapping pair will
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. ttttrrrr((((1111))))                                                                    ttttrrrr((((1111))))
  137.  
  138.  
  139.  
  140.              be in the array for _s_t_r_i_n_g_2 in the same relative position.
  141.  
  142.              Except for case conversion, the characters specified by a
  143.              character class expression are placed in the array in an
  144.              unspecified order.
  145.  
  146.              If the name specified for _c_l_a_s_s does not define a valid character
  147.              class in the current locale, the behaviour is undefined.
  148.  
  149.      _[[[[_====_eeee_qqqq_uuuu_iiii_vvvv_====_]]]]
  150.              Represents all characters or collating elements belonging to the
  151.              same equivalence class as _e_q_u_i_v, as defined by the current
  152.              setting of the LC_COLLATE locale category. An equivalence class
  153.              expression is allowed only in _s_t_r_i_n_g_1, or in _s_t_r_i_n_g_2 when it is
  154.              being used by the combined _----_dddd and _----_ssss_]]]] options. The characters
  155.              belonging to the equivalence class are placed in the array in an
  156.              unspecified order.
  157.  
  158.      _[[[[_xxxx_****_nnnn_]]]]   Represents _n repeated occurrences of the character _x. Because
  159.              this expression is used to map multiple characters to one, it is
  160.              only valid when it occurs in _s_t_r_i_n_g_2. If _n is omitted or is zero,
  161.              it is interpreted as large enough to extend the _s_t_r_i_n_g_2-based
  162.              sequence to the length of the _s_t_r_i_n_g_1-based sequence. If _n has a
  163.              leading zero, it is interpreted as an octal value. Otherwise, it
  164.              is interpreted as a decimal value.
  165.  
  166.      When the _----_dddd option is not specified:
  167.  
  168.      Each input character found in the array specified by _s_t_r_i_n_g_1 is replaced
  169.      by the character in the same relative position in the array specified by
  170.      _s_t_r_i_n_g_2. When the array specified by _s_t_r_i_n_g_2 is shorter that the one
  171.      specified by _s_t_r_i_n_g_1, the results are unspecified.
  172.  
  173.      If the _----_cccc option is specified, the complements of the characters
  174.      specified by _s_t_r_i_n_g_1 (the set of all characters in the current character
  175.      set, as defined by the current setting of LC_CTYPE, except for those
  176.      actually specified in the _s_t_r_i_n_g_1 operand) are placed in the array in
  177.      ascending collation sequence, as defined by the current setting of
  178.      LC_COLLATE.
  179.  
  180.      Because the order in which characters specified by character class
  181.      expressions or equivalence class expressions is undefined, such
  182.      expressions should only be used if the intent is to map several
  183.      characters into one. An exception is case conversion, as described
  184.      previously.
  185.  
  186.      When the _----_dddd option is specified:
  187.  
  188.      Input characters found in the array specified by _s_t_r_i_n_g_1 will be deleted.
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. ttttrrrr((((1111))))                                                                    ttttrrrr((((1111))))
  203.  
  204.  
  205.  
  206.      When the _----_cccc option is specified with _----_dddd , all characters except those
  207.      specified by _s_t_r_i_n_g_1 will be deleted. The contents of _s_t_r_i_n_g_2 will be
  208.      ignored, unless the _----_ssss option is also specified.
  209.  
  210.      The same string cannot be used for both the _----_dddd and the _----_ssss option; when
  211.      both options are specified, both _s_t_r_i_n_g_1 (used for deletion) and _s_t_r_i_n_g_2
  212.      (used for squeezing) are required.
  213.  
  214.      When the _----_ssss option is specified, after any deletions or translations have
  215.      taken place, repeated sequences of the same character will be replaced by
  216.      one occurrence of the same character, if the character is found in the
  217.      array specified by the last operand. If the last operand contains a
  218.      character class, such as the following example:
  219.  
  220.          _tttt_rrrr _----_ssss _''''_[[[[_::::_ssss_pppp_aaaa_cccc_eeee_::::_]]]]_''''
  221.  
  222.      the last operand's array will contain all of the characters in that
  223.      character class. However, in a case conversion, as described previously,
  224.      such as:
  225.  
  226.          _tttt_rrrr _----_ssss _''''_[[[[_::::_uuuu_pppp_pppp_eeee_rrrr_::::_]]]]_'''' _''''_[[[[_::::_llll_oooo_wwww_eeee_rrrr_::::_]]]]_''''
  227.  
  228.      the last operand's array will contain only those characters defined as
  229.      the second characters in each of the _tttt_oooo_uuuu_pppp_pppp_eeee_rrrr or _tttt_oooo_llll_oooo_wwww_eeee_rrrr character pairs,
  230.      as appropriate.
  231.  
  232.      An empty string used for _s_t_r_i_n_g_1 or _s_t_r_i_n_g_2 produces undefined results.
  233.  
  234. EEEEXXXXAAAAMMMMPPPPLLLLEEEESSSS
  235.      The following example creates a list of all the words in _f_i_l_e_1 one per
  236.      line in _f_i_l_e_2, where a word is taken to be a maximal string of
  237.      alphabetics.  The strings are quoted to protect the special characters
  238.      from interpretation by the shell; 012 is the ASCII code for newline.
  239.  
  240.           _tttt_rrrr _----_cccc_ssss _""""_[[[[_AAAA_----_ZZZZ_]]]]_[[[[_aaaa_----_zzzz_]]]]_"""" _""""_[[[[_\\\\_0000_1111_2222_****_]]]]_"""" _<<<< _f_i_l_e_1 _>>>> _f_i_l_e_2
  241.      The following example creates a list of all words in _f_i_l_e_1 one per line
  242.      in _f_i_l_e_2, where a word is taken to be a maximal string of letters.
  243.  
  244.           _tttt_rrrr _----_cccc_ssss _""""_[[[[_::::_aaaa_llll_pppp_hhhh_aaaa_::::_]]]]_"""" _""""_[[[[_\\\\_nnnn_****_]]]]_"""" _<<<< _f_i_l_e_1 _>>>> _f_i_l_e_2
  245.      The next example translates all lower-case characters in _f_i_l_e_1 to upper-
  246.      case and writes the results to standard output.
  247.  
  248.           _tttt_rrrr _""""_[[[[_::::_llll_oooo_wwww_eeee_rrrr_::::_]]]]_"""" _""""_[[[[_::::_uuuu_pppp_pppp_eeee_rrrr_::::_]]]]_"""" _<<<< _f_i_l_e_1
  249.      Note that the caveat expressed in the corresponding Issue 3 example is no
  250.      longer in effect. This case conversion is now a special case that employs
  251.      the _tttt_oooo_llll_oooo_wwww_eeee_rrrr and _tttt_oooo_uuuu_pppp_pppp_eeee_rrrr classifications, ensuring that proper mapping is
  252.      accomplished (when the locale is correctly defined).
  253.  
  254.  
  255.  
  256.                                                                         PPPPaaaaggggeeee 4444
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263. ttttrrrr((((1111))))                                                                    ttttrrrr((((1111))))
  264.  
  265.  
  266.  
  267.      This example uses an equivalence class to identify accented variants of
  268.      the base character e in _f_i_l_e_1, which are stripped of diacritical marks
  269.      and written to _f_i_l_e_2.
  270.           _tttt_rrrr _""""_[[[[_====_eeee_====_]]]]_"""" _eeee _<<<< _f_i_l_e_1 _>>>> _f_i_l_e_2
  271. EEEEXXXXIIIITTTT SSSSTTTTAAAATTTTUUUUSSSS
  272.      The following exit values are returned:
  273.  
  274.                0   All input was processed successfully.
  275.               >0   An error occurred.
  276. AAAAPPPPPPPPLLLLIIIICCCCAAAATTTTIIIIOOOONNNN UUUUSSSSAAAAGGGGEEEE
  277.      If necessary, _s_t_r_i_n_g_1 and _s_t_r_i_n_g_2 can be quoted to avoid pattern matching
  278.      by the shell.
  279.  
  280.      If an ordinary digit (representing itself) is to follow an octal
  281.      sequence, the octal sequence must use the full three digits to avoid
  282.      ambiguity.
  283.  
  284.      When _s_t_r_i_n_g_2 is shorter than _s_t_r_i_n_g_1, a difference results between
  285.      historical System V and BSD systems. A BSD system will pad _s_t_r_i_n_g_2 with
  286.      the last character found in _s_t_r_i_n_g_2.  Thus, it is possible to do the
  287.      following:
  288.  
  289.           _tttt_rrrr _0000_1111_2222_3333_4444_5555_6666_7777_8888_9999 _dddd
  290.      which would translate all digits to the letter _d. Since this area is
  291.      specifically unspecified in the document, both the BSD and System V
  292.      behaviours are allowed, but a portable application cannot rely on the BSD
  293.      behaviour. It would have to code the example in the following way:
  294.  
  295.           _tttt_rrrr _0000_1111_2222_3333_4444_5555_6666_7777_8888_9999 _''''_[[[[_dddd_****_]]]]_''''
  296.      It should be noted that, despite similarities in appearance, the string
  297.      operands used by _tttt_rrrr are not regular expressions.
  298.  
  299.      NUL characters can be stripped by using _tttt_rrrr _----_dddd _''''_\\\\_0000_0000_0000_''''.
  300.  
  301. FFFFIIIILLLLEEEESSSS
  302.      _////_uuuu_ssss_rrrr_////_llll_iiii_bbbb_////_llll_oooo_cccc_aaaa_llll_eeee_////_l_o_c_a_l_e_////_LLLL_CCCC______MMMM_EEEE_SSSS_SSSS_AAAA_GGGG_EEEE_SSSS_////_uuuu_xxxx_cccc_oooo_rrrr_eeee_...._aaaa_bbbb_iiii
  303.           language-specific message file [See _LLLL_AAAA_NNNN_GGGG on _eeee_nnnn_vvvv_iiii_rrrr_oooo_nnnn(5).]
  304.  
  305. RRRREEEEFFFFEEEERRRREEEENNNNCCCCEEEESSSS
  306.      _aaaa_ssss_cccc_iiii_iiii(5), _eeee_dddd(1), _ssss_hhhh(1)
  307.  
  308. NNNNOOOOTTTTIIIICCCCEEEESSSS
  309.      _tttt_rrrr will not handle ASCII _NNNN_UUUU_LLLL in _s_t_r_i_n_g_1 or _s_t_r_i_n_g_2; it always deletes _NNNN_UUUU_LLLL
  310.      from input.
  311.  
  312.  
  313.  
  314.  
  315.  
  316.                                                                         PPPPaaaaggggeeee 5555
  317.  
  318.  
  319.  
  320.